import Vue from 'vue';
import App from './App';
import router from './router';
import './config/bootstrap.js';
import G2 from '@antv/g2';
import 'element-ui/lib/theme-chalk/index.css';
import {Popover , Collapse , CollapseItem} from 'element-ui';
Vue.use(Popover);
Vue.use(Collapse);
Vue.use(CollapseItem);

Vue.config.productionTip = false;
Vue.use(G2);
router.beforeEach(async (to, from, next) => {
    const checkRoute = from.path === '/' && !from.name && to.path !== '/login'  && to.path !== '/register';

    const hasToken = SessionStore.get('loginMesg') && SessionStore.get('loginMesg').token;
    if (checkRoute && !hasToken) {
        next('/login');
    }
    next();
});

new Vue({
    el: '#app',
    router,
    components: {App},
    template: '<App/>',
});
